<?php

global $folders;
global $area;
global $section;
global $file;



//echo $_SERVER["REQUEST_URI"];

//if (isset($_SERVER['REDIRECT_URI'])) {
	$folders = explode ("/", $_SERVER['REQUEST_URI']);
	$file =  basename($_SERVER['REQUEST_URI']);
	
//} else {	
	
//	$folders = explode ("/", $_SERVER['REDIRECT_URL']);
//	$file =  basename($_SERVER['REDIRECT_URL']);
//}

//echo "{$_SERVER["PHP_SELF"]}";

if ($file != "admin") $_SESSION["last_page"] = $_SERVER['REQUEST_URI'];


//$folders = explode ("/", $_SERVER['REQUEST_URI']);
//$file =  basename($_SERVER['REQUEST_URI']);
if ($file == "main.asp") $file = "index.html";
//if ($file != "admin") $_SESSION["last_page"] = $_SERVER['REQUEST_URI'];


$check=count($folders);
#$section="main";
#$area="";

/*
Area -> Section -> File
*/
$section="";
$area="";

switch ($check) {
    case 0:
        $section = "main";
        $area = "";
        break;
    case 1:
        $section = "main";
        if (strpos($folders[0],".")>0) $area="";
        else $area = $folders[0];
        break;
    case 2: 
        $section = "main";
        if (empty($folders[1])) $area = "";
        else {
            if (strpos($folders[1],".")==0) $area = $folders[1];
            else $area = "";
        }
        break;
    case 3:
       $section = "main";
       $area = $folders[1]; 
       break;
    case 4:
        $area = $folders[1];
        $section = $folders[2];
        break;
     case 5:
        $area = $folders[1];
        $section = $folders[2];
        $subsection = $folders[3];
        break;
}

?>